Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redox: correct is_absolute() and has_root() #43983

Merged
merged 4 commits into from Aug 23, 2017

Conversation

ids1024
Copy link
Contributor

@ids1024 ids1024 commented Aug 18, 2017

This is awkward, but representing schemes properly in Components is not easily possible without breaking backwards compatibility, as discussed earlier in #37702.

But these methods can be corrected anyway.

Redox paths are problematic. It would make sense to add a `Scheme`
variant to the `std::path::Component` enum; but that would presumably be
a breaking change due to exhaustive matching. Alternately it could use
the existing `Prefix` variant, like Windows, but none of the existing
types of prefix make sense, Redox only has one kind, and adding a new
variant to that enum has the same issue as `Component`.
@rust-highfive
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

Can this avoid the usage of #[cfg] and instead use cfg! instead? Also presumably this could add a few tests?

@ids1024
Copy link
Contributor Author

ids1024 commented Aug 22, 2017

I changed it the cfg!. It should be possible to add #[cfg(target_os = "redox")] tests alongside the current Unix and Windows ones in this file, although they presumably wouldn't run on CI and I'm frankly not quite sure how to run run the libstd unit tests on Redox (since it isn't possible to build Rust under Redox itself yet)....

@@ -323,6 +323,13 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr {
mem::transmute(s)
}

// Detect scheme on Redox
#[inline]
#[allow(unused_variables)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think either annotation here is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right; inlining probably will happen anyway. The allow was needed with #[cfg] since the argument was unused on non-Redox, but is unneeded now.

// Detect scheme on Redox
#[inline]
#[allow(unused_variables)]
fn has_scheme(s: &[u8]) -> bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be something like has_redox_scheme?

@@ -605,6 +612,9 @@ pub struct Components<'a> {
// normalization, e.g. \\server\share == \\server\share\.
has_physical_root: bool,

// For Redox
has_scheme: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be avoided and the has_physical_root above be generalized?

@alexcrichton
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Aug 22, 2017

📌 Commit fe2d661 has been approved by alexcrichton

@arielb1 arielb1 added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 22, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Aug 23, 2017
…ichton

Redox: correct is_absolute() and has_root()

This is awkward, but representing schemes properly in `Components` is not easily possible without breaking backwards compatibility, as discussed earlier in rust-lang#37702.

But these methods can be corrected anyway.
bors added a commit that referenced this pull request Aug 23, 2017
Rollup of 8 pull requests

- Successful merges: #43631, #43977, #43983, #44016, #44039, #44043, #44047, #44054
- Failed merges:
@bors bors merged commit fe2d661 into rust-lang:master Aug 23, 2017
@ids1024 ids1024 deleted the redox-path-prefix branch October 5, 2017 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants